package com.example.mapper;


import com.example.entity.Course;
import com.example.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface StudentMapper {

    @Select("select * from student where username = #{username}")
    Student selectByUsername(String username);
    @Select("select * from student where id = #{id}")
    Student selectById(Integer id);

    @Insert("INSERT into student (username,password,name,age,sex,phone,identi,avatar,role)"+
            "values (#{username},#{password},#{name},#{age},#{sex},#{phone},#{identi},#{avatar},#{role})")
    void insert(Student student);
    @Update("UPDATE student set username = #{username}, password = #{password},name = #{name}, age = #{age}, sex = #{sex}, " +
            "phone = #{phone},identi = #{identi},avatar = #{avatar} WHERE id = #{id}")
    void updateById(Student student);
    @Delete("DELETE from student where id =#{id}")
    void deleteById(Integer id);
    @Select("select * from student where username like concat('%',#{username},'%') " +
            "and name like concat ('%',#{name},'%') order by id desc") //desc
    List<Student> selectAll(Student student);
}
